package com.boot.springboot.service.serviceImpl;

import com.boot.springboot.dao.EmpDao;
import com.boot.springboot.dao.UserDao;
import com.boot.springboot.entity.Emp;
import com.boot.springboot.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    EmpDao empDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Emp> findAll() {
        return empDao.findAll();
    }

    @Override
    public boolean addEmp(Emp emp) {
        emp.setId(UUID.randomUUID().toString());
        boolean is = empDao.addEmp(emp);
        return is;
    }

    @Override
    public void deleteEmpById(String id) {
        empDao.deleteEmpById(id);
    }

    @Override
    public void updateEmpById(Emp emp) {
         empDao.updateEmpById(emp);
    }

    @Override
    public Emp getEmpById(String id) {
        return empDao.getEmpById(id);
    }
}
